package bean;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;

public class BannerWorker implements ResourceLoaderAware{
	private ResourceLoader loader;
	@Override
	public void setResourceLoader(ResourceLoader loader) {
		this.loader=loader;
	}
	
	public void showBanner() throws Exception{
		String filePath = "banner.txt"; //放于classpath根目录
//		String filePath = "classpath:myspring/bean/banner.txt";
//		String filePath = "file:d:/myspring/banner.txt";
		Resource res = loader.getResource(filePath);
		InputStream ins = res.getInputStream();
		BufferedReader reader = new BufferedReader( new InputStreamReader(ins) );
		while (true){
			String line = reader.readLine();
			if (null == line) break;
			System.out.println(line);
		}
		reader.close();
		
	}

}
